<?php
/***********************************************************
 * Base Admin Controller
 ***********************************************************/

require_once 'Zend/Session/Namespace.php';
require_once 'CMS/Mvc/BaseController.php';

abstract class BaseAdminController extends BaseController
{
	public function init()
	{
		parent::init();
		//$this->messageManager->LoadMessages(APPLICATION_PATH . '/definitions/messages.xml');
	}
    /**
     * get user information from database
     */
    
   public function isAdminLoggedin()
	{
		$session = $this->sessionCreate(ADMIN_LOGINID_NAMESPACE);

		if(!isset($session->loginID)){
			$this->view->LoggedIn = false;
			return false;
		}

		$this->view->LoggedIn = true;
		return true;
	}	
	
	/**
	 * session login id creator
	*/
	public function sessionAdminLoginIdCreate($id,$name)
	{
		$sessionLogin = new Zend_Session_Namespace(ADMIN_LOGINID_NAMESPACE);
		$sessionLogin->loginID = $id;
		$sessionLogin->setExpirationSeconds(1800);
	}	
	
	/**
	 * session login id destroyer
	*/
	public function sessionAdminLoginIdDestroy()
	{
		try {
			Zend_Session::namespaceUnset(ADMIN_LOGINID_NAMESPACE);
			
		} catch (Exception $e) {
			return false;
		}
	}	
	
		public function redirectAdminLogin(){
		$this->_redirect("/admin/login/index");
	}	
	
	/**
	 * get loggedin user ID from session
	 */

	public function getSessionAdmin(){
		$user_id = $this->sessionCreate(ADMIN_LOGINID_NAMESPACE)->loginID;
		return $user_id;
	}	
	
}